package java.wxw;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @author wangxianwei
 * @create 2020--06--30--16:18
 */
//退出文件系统
public class FileExit extends Final{
    private int i, j;
    String str;
    SetPANo setPANo =new SetPANo();
    public void quitF() throws IOException {
        setPANo.setPANo(1);/*设置物理地址号(表示该地址号是否被用了0-未用,1-已用),RorW是0-read,1-write*/
        for(j=0;j<userDirCount;j++) {
            FileOutputStream fileOutputStream = new FileOutputStream("c:\\osfile\\");

            for (i = 0; i < fileCount[j];i++){
                FileInputStream inputStream =new FileInputStream(String.valueOf(userDirs[j].userFile[i]));
                byte[] buf = new byte[1024];//每次读入文件数据量
                int len = -1;
                StringBuffer sbuf = new StringBuffer("");
                while ((len = (inputStream.read(buf))) != -1) {
                    sbuf.append(new String(buf, 0, len));//将 buf 数组参数的子数组的字符串表示形式追加到此序列
                    //从0开始,遇到len（-1）结束
                }
                fileOutputStream.write(buf);
            }
        }
    }
}
